home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / var / lib / dpkg / info / splix.postinst < prev    next >
Text File  |  2009-09-18  |  3KB  |  79 lines

  1. #!/bin/bash
  2. # postinst script for splix
  3. #
  4. # see: dh_installdeb(1)
  5.  
  6. set -e
  7.  
  8. # summary of how this script can be called:
  9. #        * <postinst> `configure' <most-recently-configured-version>
  10. #        * <old-postinst> `abort-upgrade' <new version>
  11. #        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
  12. #          <new-version>
  13. #        * <postinst> `abort-remove'
  14. #        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
  15. #          <failed-install-package> <version> `removing'
  16. #          <conflicting-package> <version>
  17. # for details, see http://www.debian.org/doc/debian-policy/ or
  18. # the debian-policy package
  19.  
  20.  
  21. case "$1" in
  22.     configure)
  23.         # Do the following only if CUPS is running and the needed CUPS tools
  24.         # are available
  25.         if which lpstat > /dev/null 2>&1 && \
  26.             which lpinfo > /dev/null 2>&1 && \
  27.             which lpadmin > /dev/null 2>&1 && \
  28.             LC_ALL=C lpstat -h /var/run/cups/cups.sock -r | grep -v not > /dev/null 2>&1; then
  29.             # Update the PPD files of all already installed print queues
  30.             driverregexp='lsb/usr/splix/'
  31.             gennicknameregexp='s/,(\s*SpliX|)(\s*V\.?|)\s*[\d\.]*$//i'
  32.             [ ! -z "$gennicknameregexp" ] && \
  33.                 gennicknameregexp="; $gennicknameregexp"
  34.             gennicknameregexp='s/\s*\(recommended\)//'"$gennicknameregexp"
  35.             tempfiles=
  36.             trap 'rm -f $tempfiles; exit 0' 0 HUP INT QUIT ILL ABRT PIPE TERM
  37.             tmpfile1=`mktemp -t updateppds.XXXXXX`
  38.             tempfiles="$tempfiles $tmpfile1"
  39.             lpinfo -h /var/run/cups/cups.sock -m | grep -E $driverregexp > $tmpfile1
  40.             cd /etc/cups/ppd
  41.             for ppd in *.ppd; do
  42.                 [ -r "$ppd" ] || continue
  43.             queue=${ppd%.ppd}
  44.                 lpstat -h /var/run/cups/cups.sock -p "$queue" >/dev/null 2>&1 || continue
  45.                 nickname=`grep '\*NickName:' "$ppd" | cut -d '"' -f 2 | perl -p -e 's/\n$//' | perl -p -e "$gennicknameregexp" | perl -p -e 's/(\W)/\\\\$1/g'`
  46.                 lang=`grep '\*LanguageVersion:' "$ppd" | cut -d ' ' -f 2 | perl -e 'print lc(<>)' | perl -p -e 's/[\r\n]//gs'`
  47.                 ppdfound="0"
  48.                 englishppduri=""
  49.                 tmpfile2=`mktemp -t updateppds.XXXXXX`
  50.                 tempfiles="$tempfiles $tmpfile2"
  51.                 cat $tmpfile1 | perl -p -e "$gennicknameregexp" | grep -E '^\S+\s+.*'"$nickname"'$' | cut -d ' ' -f 1 > $tmpfile2
  52.                 while read newppduri; do
  53.                     [ "$ppdfound" = "0" ] && lpadmin -h /var/run/cups/cups.sock -p "$queue" -m $newppduri 2>/dev/null || continue
  54.                     newlang=`grep '\*LanguageVersion:' "$ppd" | cut -d ' ' -f 2 | perl -e 'print lc(<>)' | perl -p -e 's/[\r\n]//gs'`
  55.                     [ "$newlang" = "$lang" ] && ppdfound="1"
  56.                     [ "$newlang" = "english" ] && englishppduri="$newppduri"
  57.                 done < $tmpfile2
  58.                 [ "$ppdfound" = "0" ] && [ ! -z "$englishppduri" ] && lpadmin -h /var/run/cups/cups.sock -p "$queue" -m $englishppduri 2>/dev/null && ppdfound="1"
  59.                 [ "$ppdfound" = "1" ] && echo PPD for printer $queue updated >&2
  60.             done
  61.         fi
  62.     ;;
  63.  
  64.     abort-upgrade|abort-remove|abort-deconfigure)
  65.     ;;
  66.  
  67.     *)
  68.         echo "postinst called with unknown argument \`$1'" >&2
  69.         exit 1
  70.     ;;
  71. esac
  72.  
  73. # dh_installdeb will replace this with shell code automatically
  74. # generated by other debhelper scripts.
  75.  
  76.  
  77.  
  78. exit 0
  79.